/* 
 * File:   TU.h
 * Author: juliano
 *
 * Created on August 6, 2012, 2:36 PM
 */

#ifndef TU_H
#define	TU_H

#include "BasicBlock.h"

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct ControlFlowGraph ControlFlowGraph;

typedef enum TU_Type{
    TUT_BB,
    TUT_CFG,
    TUT_NONE
}TU_Type;

typedef struct TranslationUnit{
    union{
        BasicBlock* BB;
        struct ControlFlowGraph* CFG;
    }NodeData;
    TU_Type Type;
    
    uint16_t(*AddressFunc)(struct TranslationUnit* TU);
    void(*CFGRepoRefreshFunc)(struct TranslationUnit* TU, ControlFlowGraph* CFG);
    uint64_t (*SizeFunc)(struct TranslationUnit* TU);
} TranslationUnit;

TranslationUnit* TU_New();
void TU_SetBB(TranslationUnit* TU, BasicBlock* BB);
void TU_SetCFG(TranslationUnit* TU, ControlFlowGraph* CFG);
BasicBlock* TU_GetBB(TranslationUnit* TU);
ControlFlowGraph* TU_GetCFG(TranslationUnit* TU);
uint16_t TU_GetStartingAddress(TranslationUnit* TU);
uint32_t TU_IsSameTU(TranslationUnit* TU1, TranslationUnit* TU2);
uint32_t TU_IsNone(TranslationUnit* TU);
uint32_t TU_GetSize(TranslationUnit* TU);

#ifdef	__cplusplus
}
#endif

#endif	/* TU_H */

